package org.jeecg.modules.payment.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.model.EnumDictOption;
import org.jeecg.common.util.EnumDictUtil;
import org.jeecg.modules.payment.service.impl.EnumDictService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
* @Description: 获取枚举字典接口
* @Author: sean
* @Date:   2024-05-28
* @Version: V1.0
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/payment/enum-dict")
public class EnumDictController {

    private final EnumDictService enumDictService;

    @GetMapping("/{dictCode}")
    public Result<List<EnumDictOption>> getEnumDictionary(@PathVariable String dictCode) {
        Class clazz =  enumDictService.getEnumByCode(dictCode);
        List<EnumDictOption> options = EnumDictUtil.getDictOption(clazz);
        return Result.ok(options);
    }

}
